![]() |
[8x8] |
Was thinking of some things I'd like to see in future PICO. Reiterating the post as quite a bit has changed since its initial writing.
Some of these suggestions are possible, others are not. What are some of your suggestions that you think would be acceptable for the next update in Pico-8 ?
Going to start latest suggestions as replies to this thread as this one post has gotten rather large.
Here we go ! First off, 2 errors:
!! Fix parenthesis error. This gives error: IF (K=="(") X=X-1 ... gives error because parenthesis is character to check.
!! Fix error with modulos when using high negative numbers. ?-32767%10000 yields 7233, incorrect.






Hello.
There are a few kinds of Pico-8 programmers out there. Those who like tabs and those who do not.
I fall into the latter category. So - what is the best way to remove tabs ? Well sure you can do it yourself - or you can rely on my rusty trusty Pico-8 program to do it for you !
NOTE: This program should be run NOT online but in LOCAL mode as it saves a file to your hard-drive, the corrected .P8 file called, "notabs."
Now at first I was using an index to read the string, but of course numbers only go up to 32767 so I had to use a different method. The code now will accept a program of ANY size now. Quite nice.
To use you have a few choices. If you know for instance that the code does NOT use the shift letters to create the Up, Down, Left, Right and other fancy icons in the source, you can use good old notepad.
Load up the .P8 file there. Run my program. Then copy all of the notepad contents (CTRL+A) (CTRL+C) to the clipboard. This is important to do in this order as when you first run my program it CLEARS the clipboard data first.
Right, then press CTRL-V. Press (O) to accept and after a short moment, whammo, you have a newly saved file called notabs.p8l ... be aware there is a trailing "L" on the file !
Rename to take it out and you're all set. Now if it crashes because of hitting a custom icon or arrow key, you'll have to load the original P8 in a more robust viewer like FIREFOX as an offline text file.
THEN run my program, open the P8 as a local file in Firefox.Press (CTRL+A) (CTRL+C), return to my program, press CTRL-V, and the P8 it saves should then run perfectly.
There may be an easier way to do this - but not with Pico-8 I think. :)
Any way to LOAD a text data file would be awesome, don't think that's going to happen though.
[b]HOPE THIS HELPS !


It's the first time I'm using the PICO-8 clock. Was just experimenting.
The time of this writing is:
09-10-19 at 1:29pm.
Let me write some code to confirm this:
cls() print("year...."..stat(80)) print("month..."..stat(81)) print("day....."..stat(82)) print("hour...."..stat(83)) print("minute.."..stat(84)) print("second.."..stat(85)) repeat flip() until forever |
Yet when I run this the HOUR says 18. Looking at the clock on my computer though it still says it's 1pm + 32-minutes. What gives ?



UPDATES: (that's all for today 09-09-19)
bugs + changes + fixes:
-
added new picture logo
-
stepped down the difficulty and checked game to level 16
i believe it's possible to beat it now -
change color each new level for mission specs
-
lowered volume of giggling, yeah we had enough
-
fixed nasty bug where 2- or more would collide and fight each other for their desired location.
now they shake hands and take off independently -
added debug to show all activity
you can also cheat quite thoroughly in this mode. :) -
added display in corner to show remaining ghosts
- fix mistyped variables, there were a few




Surprisingly with all the updates PICO-8 has received, it has one gross error in it that took me hours to debug and later find out and break it into the exact components giving the error alone. It was definitely a case of "it's not my fault." Could cause problems later in other carts and programs.
This will not run:
if (key=="(") print"open" |
This will also not run:
if (key==")") print"close" |
This will run:
if (key=="[") print"open" |
Wow. And no-one's discovered this till now ??





Update: Added GRAY, bars, text, Hopalong Cassidy
Hello.
As you know, a new palette method was discovered. Now while you can't use all 32-colors in one screen (which is what I had hoped), you CAN tweak individual palettes of the 16 to use the new set.
This means for those of you who want to make games that use only one HUE, then you might find this program useful.
It shows 6-squares going from darkest but not black to each color of purple, red, orange, yellow, green, and blue, using the (O) key to change between, and the coding involved to produce it.
I have since added a picture of Hopalong Cassidy. This was not easy. First I converted a square picture of him to 128x128 B&W. Then manually created a palette based on the 7-colors that comprise of (Gray). Then reissue the image using that palette.
Then manually modify the palette only to default PICO-8 standard. Import. Re-hue, done. He looks best in the GRAY hue because that is the picture he was originally, B&W.
Would be keen to have optional 16-shades of B&W. :D Maybe next PICO-8 release.



Alright, well believe it or not this would actually be the FIRST platformer I have ever written, one where you have an actual map to navigate let alone a wall-jumping sprite.
Years ago I did make some action games that worked on grids using HIRES and LORES on the Apple computer, but as I got older I wanted more and more to make turn-based thinking games relying less on human-made maps and more on computer-generated - and that is my primary focus today.
Well - this is certainly not what is happening here.
In any case, it is complete, and hopefully others can learn from the code and make good carts from it.
The first thing it does is create a sample playfield for the player to explore.
Then you have a cursor letting you place your player sprite. Use arrow keys to navigate the 64x32 area and press O to do so.
Finally you are in Testplay. Arrow keys control the player. Press O to jump and X to return to select player position.
To Wall Jump, jump then hit a wall just as you are getting ready to fall. Your player will grip the side of the wall and then fling off in the opposite direction. You can use this to climb a narrow chimney for instance.
[b]HOPE THIS HELPS !


Was working on the code to randomly generate a presentable field for a platformer engine to testplay in, got to writing this code and while I won't be using it there, perhaps you can find a use for it ?
It's unusual in that it creates a maze pattern in any hollow region. Cart follows:





As Platformers seems to be on the tips and brains of people, I remember someone once mentioned it was difficult to make a platformer. If you have a reasonable background in math, I think it can be done fairly easily.
Here then is my sample engine to demonstrate how it can be done. I have geared this particular engine to match as closely as I can Nintendo's own Super Mario Bros game without using look-up tables.
Keys are LEFT, RIGHT, and (O) to jump.
Note also I am multiplying everything by 100. The reason is simple. Most programming languages start to give incorrect values even doing simple things like subtracting .1 or .05 from a real number. By keeping everything integer, you do not have problems with the limitations of the language's inability to handle real numbers.



You may have seen a few rare carts read the keyboard. I wrote this simple program to demonstrate easily how it can be done.
It also introduces two useful functions of CHR() and ASC() where CHR(n) returns the character equivalent from an ASCII value N whereas ASC(n) returns the ASCII equivalent from the character N.
It is important to note that I have reversed the values of 65-90 and 97-122 respectively as in PICO-8, pressing "A" by itself normally gives 97 despite its appearance being uppercase.
You are welcome to change the table back if you like.
If you don't want to use BTNP() or BTN() to return your arrow keys, you can hit NUM-LOCK and use "2" "4" "6" and "8" respectively to emulate arrow motions. Additionally, "1" "3" "7" and "9" for single stroke diagonals !
function wait() repeat flip() until btnp(4) end function count() cls() for i=1,3 do print(i) end end i=6 count() wait() print("") print(i) print("") wait() for i=1,3 do print(i) end wait() print("") print(i) print("done!") repeat flip() until forever |
By looking at this code you would think the end result would be 4 each time, both in the function and in the main program as most programming languages would return that value. But this is not the case with PICO-8. Instead the result will be what you defined globally, in this case 6.
So it's important to remember that the index variable in ANY FOR/END statements, either directly in your main code or in a function - will ALWAYS be local to the loop.
So you need NEVER define LOCAL variables in a function that will only be used in FOR/END statements. Good to know.


While I have seen the ATARI 2600 do this several times to save on space, it's a shame that PICO-8 does not have a scaling function for the default 3x5 font. In the original Haunted House or "Mildew's Manor" game, I made use of this double-size method in the menu.
Here now you can have it to use in your own code. See demo enclosed.
HOPE THIS HELPS !


While I don't think PICO-8 has any appreciable VSYNC ability, you can indeed make use of this rare command to stop the screen from tearing when updating massive pixels as seen here:
If the HoldFrame flag is off, in immediate mode (and possibly not from a browser execution) my screen gets a wiggly line about 3/4 of the way down the screen when doing this update.
If you invoke the seldom used command HOLDFRAME() however, you can prevent against this for games played as an EXE or in immediate mode. Check the source for details.
HOPE THIS HELPS !


I was reading earlier about the Fisher-Yates Shuffle method and - well, I'm a little confused. What is the purpose of its complexity ?
I mean if you just want to shuffle a deck of cards, for instance, you can do so in code as simple as this:
-- simple card shuffler -- written by dw817 -- initialize variables deck={} rank="a23456789tjqk" suit="schd" -- build sorted deck for i=0,3 do for j=0,12 do deck[j+i*13]=sub(rank,j+1,j+1)..sub(suit,i+1,i+1) end end ::again:: -- display current deck cls() for i=0,3 do for j=0,12 do print(deck[j+i*13],j*10,i*8,13) end end print("press a key to shuffle",0,64,7) repeat flip() until btnp(🅾️) -- shuffle that deck for i=0,51 do r=flr(rnd()*52) deck[i],deck[r]=deck[r],deck[i] end goto again |




I was curious to know if it was possible to recode the key to pause a cart during runtime. That is, directly in the source-code itself.
If you go to make a program that asks your name and reads the real keyboard via poke 24365,1, if you hit letter "P" it will pause with an interrupt menu. Is there some way, in code, poke or otherwise, to reconfigure the pause key to something like "ESC" or backwards apostrophe "`" ?
How can this be done ?




While there is no true PCOPY() command yet for Pico-8, you can certainly simulate having 3-extra virtual pages that will cost you no tiles, no mapper, and even no array space - if you are content to use the resolution of 64x64. In this two new commands are introduced. PCOPY() which will copy a page number from 0 to 3 back to a different page number 0 to 3 where zero is the display page.
It uses MEMCPY() so it should be fast enough.
Changed to use PGET() as apparently memcpy() does not work incrementally.
Doing so you can create images on the other three pages and recall them anytime you want.
You plot pixels using the PST() command where the first argument is page # (0-3), then x-coordinate, then y-coordinate, then color.
If you want to be able to record the screen and use it as a static image for your games, you can do so fairly easily as long as you don't need more than 128- 8x8 graphic characters and don't need the mapper space at all.
With this out of the way you can use
memcpy(4096,24576,8192) |
to record the screen, and
memcpy(24576,4096,8192) |
to recover the screen. See the source code for the cart above for the code to do so.
This is useful if you are doing more than just a few simple images that can be redrawn, especially if they are elements that are randomly placed. Using memcpy() will be a lot faster and not require you to use arrays to redraw everything exactly like it was. You might even be able to use this method in your current and future projects.
For those learning PICO-8, you may have heard that you can write carts that access the hardware mouse. While the information to do this is not readily apparent, I put together this simple demonstration program with remarks to show how you can do it by reading the position and both buttons of the device.
-- simple introduction to -- using stat(32,33,34) -- for reading the mouse -- by dw817 -- (08-01-19) -- -- poke(24365,1) -- enables keyboard + mouse -- -- stat(32) mouse-x position -- stat(33) mouse-y position -- stat(34) =1 if left button -- stat(34) =2 if right button -- stat(34) =3 both buttons -- -- flip() updates the screen cls() poke(24365,1) -- enable mouse c=7 repeat color(7) -- if right-button pressed, -- change plotting color if stat(34)==2 then c=c+1 if (c==16) c=1 -- if both buttons pressed, -- clear the screen elseif stat(34)==3 then cls() end -- read x+y position of mouse x=stat(32) y=stat(33) -- if left button pressed, -- draw on screen if stat(34)==1 then if ox!=nil then line(ox,oy,x,y,c) end ox=x oy=y else ox=nil end p=pget(x,y) pset(x,y,c) flip() pset(x,y,p) -- loop until press [esc] until forever |


For you new people at PICO-8 and even some of you veterans, you may or may not be aware that you can create a BATCH file to run PICO-8 with very precise settings. Here is the one I use:
CONTENTS OF P8.BAT
@run-pico8.exe -gif_len 120 -windowed 1 -width 692 -height 650 -draw_rect 10,5,672,640 -sound 64 -music 64 -pixel_perfect 0 -software_blit 1 -desktop c:\david\games\pico-8\pico-8_win32\roms\_snaps -home c:\david\games\pico-8\pico-8_win32 |
You can use this as a SHORTCUT too but it is too long, I think a Windows shortcut only allows 64-characters. So if you can, a BATCH file will work just as well.
Modify to your liking and - Hope This Helps !
-- 256-colors rehashed -- i think this is as fast as -- i can get the code. -- you will notice that the -- loop only moves a section -- of memory per frame now. mode=0 p=0 cls() function _update60() p=1-p if mode==0 or mode==1 then sfx(0) -- confirm drawing fillp(23130) if(p>0)fillp(-23131) for i=0,15 do for j=0,7 do rectfill(i*8,j*8,i*8+7,j*8+7,i+j*16) end end if mode==0 then memcpy(0,24576,4096) mode=1 elseif mode==1 then memcpy(4096,24576,4096) mode=2 end else if p==0 then memcpy(24576,0,4096) else memcpy(24576,4096,4096) end end end |



